<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div>
        <p id="demo">单击按钮给定与“2.5”最接近的整数</p>
        <button onclick="myFunction()">点我</button>
        <script>
            function myFunction() {
                document.getElementById("demo").innerHTML = Math.round(2.5);
            }
        </script>
    </div>
    <hr />
    <div>
        <p id="qwe">点击按钮显示一个随机数</p>
        <button onclick="awd()">点我</button>
        <script>
            function awd() {
                document.getElementById("qwe").innerHTML = Math.random();
            }
        </script>

    </div>
</body>

</html>